const ClassModel = require("../model/ClassModel")

const ClassService = {
    getList:async () => {
        //联系role集合查询
        return await ClassModel.find()
    },
    addList:async (body) => {
        // return await ClassModel.create(body)
        return await ClassModel.findOneAndUpdate({
            title:body.title
        },{
            '$set':body
        },{upsert:true,returnDocument:'after'})
        // return await ClassModel.updateOne({
        //     title:body.title
        // },{
        //     '$set':body
        // },{upsert:true})
    },
    deleteList:async(id) => {
        return await ClassModel.findByIdAndDelete(id)
    },
    // updateList:async(id,body) => {
    //     return await ClassModel.findByIdAndUpdate(id,body)
    // }
}
module.exports = ClassService